home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / dev / GUI / BGUI / AmigaE / examples / test.e < prev   
Text File  |  1994-10-05  |  6KB  |  135 lines

  1. ;/* Execute me to compile.
  2. ecomp test bgui_macros.pma
  3. quit
  4. */
  5. /*
  6. **      A small example of BGUI in Amiga E.
  7. **
  8. **      I have little knowledge of the E language so
  9. **      please forgive me if something is wrong or if
  10. **      something could have been done easier.
  11. **
  12. **      Use the "EComp" script to compile this source.
  13. **/
  14. OPT OSVERSION=37
  15.  
  16. MODULE 'libraries/bgui',
  17.        'libraries/gadtools',
  18.        'bgui',
  19.        'tools/boopsi',
  20.        'utility/tagitem',
  21.        'intuition/classes',
  22.        'intuition/classusr',
  23.        'intuition/gadgetclass'
  24.  
  25. /*
  26. **      Quit gadget/menu ID.
  27. **/
  28. CONST   ID_QUIT = 1
  29.  
  30. /*
  31. **      And were off.
  32. **/
  33. PROC main()
  34.         DEF     wd_obj, running = TRUE, rc = 0, signal
  35.         DEF     gd_quit, info_text : PTR TO CHAR
  36.  
  37.         /*
  38.         **      Text for the information class object.
  39.         **/
  40.         info_text := '\ecThis demonstration program shows you\n'+
  41.                      'how you can use BGUI with \ebAmiga E\en.\n\n' +
  42.                      'Since I only have little knowledge about this\n' +
  43.                      'language it might be possible that the code\n' +
  44.                      'looks a bit strange to you. Sorry...'
  45.  
  46.         /*
  47.         **      Open the library.
  48.         **/
  49.         IF bguibase := OpenLibrary( 'bgui.library', 37 )
  50.                 /*
  51.                 **      Create a window object.
  52.                 **/
  53.                 wd_obj := WindowObject,
  54.                         WINDOW_TITLE,         'BGUI in Amiga E',
  55.                         /*
  56.                         **    A very small menu strip.
  57.                         **/
  58.                         WINDOW_MENUSTRIP,
  59.                                 [ NM_TITLE, 0, 'Project', NIL, 0, 0, NIL,
  60.                                   NM_ITEM,  0, 'Quit',    'Q', 0, 0, ID_QUIT,
  61.                                   NM_END,   0, NIL,       NIL, 0, 0, NIL ] : newmenu,
  62.                         WINDOW_MASTERGROUP,
  63.                                 /*
  64.                                 **      A vertical master group.
  65.                                 **/
  66.                                 VGroupObject, Spacing( 4 ), HOffset( 4 ), VOffset( 4 ), GROUP_BACKFILL, SHINE_RASTER,
  67.                                         StartMember,
  68.                                                 InfoFixed( NIL, info_text, NIL, 6 ),
  69.                                         EndMember,
  70.                                         StartMember,
  71.                                                 HGroupObject,
  72.                                                         VarSpace( DEFAULT_WEIGHT ),
  73.                                                         StartMember, gd_quit := KeyButton( '_Quit', ID_QUIT ), EndMember,
  74.                                                         VarSpace( DEFAULT_WEIGHT ),
  75.                                                 EndObject, FixMinHeight,
  76.                                         EndMember,
  77.                                 EndObject,
  78.                         EndObject
  79.  
  80.                 /*
  81.                 **      Object created OK?
  82.                 **/
  83.                 IF wd_obj
  84.                         /*
  85.                         **      Attach hotkey for the quit gadget.
  86.                         **/
  87.                         IF GadgetKey( wd_obj, gd_quit, 'q' )
  88.                                 /*
  89.                                 **      Open up the window.
  90.                                 **/
  91.                                 IF WindowOpen( wd_obj )
  92.                                         /*
  93.                                         **      Obtain signal mask.
  94.                                         **/
  95.                                         GetAttr( WINDOW_SIGMASK, wd_obj, {signal} )
  96.                                         /*
  97.                                         **      Poll messages.
  98.                                         **/
  99.                                         WHILE running = TRUE
  100.                                                 /*
  101.                                                 **      Wait for the signal.
  102.                                                 **/
  103.                                                 Wait( signal )
  104.                                                 /*
  105.                                                 **      Call uppon the event handler.
  106.                                                 **/
  107.                                                 WHILE ( rc := HandleEvent( wd_obj )) <> WMHI_NOMORE
  108.                                                         SELECT rc
  109.                                                                 CASE    WMHI_CLOSEWINDOW
  110.                                                                         running := FALSE
  111.                                                                 CASE    ID_QUIT
  112.                                                                         running := FALSE
  113.                                                         ENDSELECT
  114.                                                 ENDWHILE
  115.                                         ENDWHILE
  116.                                 ENDIF
  117.                         ELSE
  118.                                 WriteF( 'Unable to attach hotkeys\n' );
  119.                         ENDIF
  120.                         /*
  121.                         **      Disposing of the object
  122.                         **      will automatically close the window
  123.                         **      and dispose of all objects that
  124.                         **      are attached to the window.
  125.                         **/
  126.                         DisposeObject( wd_obj )
  127.                 ELSE
  128.                         WriteF( 'Unable to create a window object\n' )
  129.                 ENDIF
  130.                 CloseLibrary(bguibase)
  131.         ELSE
  132.                 WriteF( 'Unable to open the bgui.library\n' )
  133.         ENDIF
  134. ENDPROC NIL
  135.